<?php
$errors = $mess = "";
include("db.php");

$front_title = "Yout sports";
$today = date("Y-m-d");
$title = "Admin";

$__self = $_SERVER['PHP_SELF'];
$GLOBALS['normalizeChars'] = array(
	'�' => 'S', '�' => 's', '�' => 'Dj', '�' => 'Z', '�' => 'z', '�' => 'A', '�' => 'A', '�' => 'A', '�' => 'A', '�' => 'A',
	'�' => 'A', '�' => 'A', '�' => 'C', '�' => 'E', '�' => 'E', '�' => 'E', '�' => 'E', '�' => 'I', '�' => 'I', '�' => 'I',
	'�' => 'I', '�' => 'N', '�' => 'O', '�' => 'O', '�' => 'O', '�' => 'O', '�' => 'O', '�' => 'O', '�' => 'U', '�' => 'U',
	'�' => 'U', '�' => 'U', '�' => 'Y', '�' => 'B', '�' => 'Ss', '�' => 'a', '�' => 'a', '�' => 'a', '�' => 'a', '�' => 'a',
	'�' => 'a', '�' => 'a', '�' => 'c', '�' => 'e', '�' => 'e', '�' => 'e', '�' => 'e', '�' => 'i', '�' => 'i', '�' => 'i',
	'�' => 'i', '�' => 'o', '�' => 'n', '�' => 'o', '�' => 'o', '�' => 'o', '�' => 'o', '�' => 'o', '�' => 'o', '�' => 'u',
	'�' => 'u', '�' => 'u', '�' => 'y', '�' => 'y', '�' => 'b', '�' => 'y', '�' => 'f');

//---------------------------------
$_noonly = " onKeyPress=\"return phoneSymbolsOnly(this, event) \"";
$_curr = "onBlur=\"this.value=formatCurrency(this.value,'');\"";
$_currDollar = "onBlur=\"this.value=formatCurrency(this.value,'$');\"";
$_ph = "onkeydown=\"javascript:backspacerDOWN(this,event);\" onkeyup=\"javascript:backspacerUP(this,event);\"";

//$rowsPerPage = 25;
//-------------------------------------------------------------------------------------------------------------
function ifSet($v)
{
	if (isset($v)) {
		return stripslashes($v);
	}
}

function activateMenu($page, $val)
{
	if ($page == $val) {
		echo "class=\"active\"";
	}
}

function ss($x)
{
	return stripslashes($x);
}

function dt2YMD($dt)
{
	return date("Y-m-d", strtotime($dt));
}

function dt2MDY($dt)
{
	return date("m/d/Y", strtotime($dt));
}

function dt2DP($dt)
{
	return date("d M Y", strtotime($dt));
}

function ModSlashes($string)
{
	if (get_magic_quotes_gpc() == 1) {
		return ($string);
	} else {
		return (addslashes($string));
	}
}

function _HS($txt)
{
	return html_entity_decode(stripslashes($txt));
}

function putSel($e, $v)
{
	if ($e == $v) {
		echo "selected=\"selected\"";
	}
}

function putChk($e, $v)
{
	if ($e == $v) {
		echo "checked=\"checked\"";
	}
}

function jsCnf($m)
{
	return "onclick=\"if (!confirm('$m')) {return false;}\"";
}

function li($e)
{
	return "<li>" . $e . "</li>";
}

function getErrors($e)
{
	return "<div class=\"error\"><h2>Erreur(s)...</h2><ul>$e</ul></div>";
}

function getSuccess($e)
{
	return "<div class=\"success\"><h2>Success...</h2><p>$e</p></div>";
}

function getADMError($e)
{
	return "<div class=\"message errormsg\"><p><ul>$e</ul></p></div>";
}

function getADMSuccess($e)
{
	return "<div class=\"message success\"><p>$e</p></div>";
}

function getADMInfo($e)
{
	return "<div class=\"message info\"><p>$e</p></div>";
}

function check_email($mail_address)
{
	$pattern = "/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/";
	if (preg_match($pattern, $mail_address)) {
		$parts = explode("@", $mail_address);
		if (function_exists('checkdnsrr')) {
			if (checkdnsrr($parts[1], "MX")) {
				return true;
			} else {
				return false;
			}
		} else {
			function checkdnsrr($host, $type = 'mx')
			{
				$res = explode("\n", strstr(shell_exec('nslookup -type=' . $type . ' ' . escapeshellarg($host) . ' 4.2.2.3'), "\n\n"));
				if ($res[2]) {
					return TRUE;
				} else {
					return FALSE;
				}
			}

			function dns_check_record($host, $type = 'mx')
			{
				return checkdnsrr($host, $type);
			}

			if (checkdnsrr($parts[1], "MX")) {
				return true;
			} else {
				return false;
			}
		}
	} else {
		return false;
	}
}

function isDuplicateEmail($e, $id = "")
{
	global $con;
	$clause = "";
	if (!empty($id)) {
		$clause = "and userID <> '$id'";
	}
	$q = $con->select_query("users", "email", "where lower(email) = '" . strtolower($e) . "' $clause");
	if ($con->total_records($q) > 0) {
		return 1;
	} else {
		return false;
	}
}

function citiesDD($city = "")
{
	global $__cities;
	$dd = "";

	for ($a = 0; $a < sizeof($__cities); $a++) {
		$s = "";
		if (!empty($city) && $city == $__cities[$a]) {
			$s = "selected = \"selected\"";
		}
		$dd .= "<option value='" . $__cities[$a] . "' $s>" . $__cities[$a] . "</option>\n";
	}
	return $dd;
}

function getCol($table, $col, $cond)
{
	global $con;
	$q = $con->select_query($table, "$col as col", "where $cond");
	if ($r = mysql_fetch_object($q)) {
		return stripslashes($r->col);
	} else {
		return "";
	}
}

function engChar($toClean)
{
	return strtr(utf8_decode($toClean), $GLOBALS['normalizeChars']);
}

function _pc($e, $v, $c)
{
	if ($e == $v) {
		return "class=\"$c\"";
	}
}

?>